package com.rxh.controller;


import com.rxh.pojo.risk.*;
import com.rxh.service.RiskService;
import com.rxh.spring.annotation.SystemLogInfo;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: Wonderming
 * Date: 2018/4/16
 * Time: 16:50
 */

@Controller
@RequestMapping(value = "/risk")
public class RiskController {

    @Resource
    private RiskService riskService;


    /*
     *   风控限次管理模块
     */

    @RequestMapping(value = "/getInit")
    @ResponseBody
    public Map<String, Object> getInit() {
        return riskService.getInit();
    }

    /*获取风控限次管理表的数据*/
    @SystemLogInfo( description = "indefinitely")
    @RequestMapping(value = "/getIndefinitely")
    @ResponseBody
    public List<RiskLimit> getIndefinitely() {
        return riskService.getIndefinitely();
    }

    /*启用与禁用模块*/
    @RequestMapping(value = "/getindefinitelyLocked")
    @ResponseBody
    public Boolean updateindefinitelyLocked(@RequestBody RiskLimit riskLimit)
    {
         return riskService.updateindefinitelyLocked(riskLimit);
    }

    /*新增用户*/
    @RequestMapping(value = "/getadd")
    @ResponseBody
    public Integer getadd(@RequestBody RiskLimit riskLimit){
         riskLimit.setCreator(SecurityContextHolder.getContext().getAuthentication().getName());
         return riskService.addRiskLimit(riskLimit);
    }

    /*判断是否能添加*/
    @RequestMapping(value = "/getindefinitelyAddCount")
    @ResponseBody
    public Integer addIndefinitely(@RequestBody RiskLimit riskLimit){
         return riskService.addIndefinitely(riskLimit);
    }

    /*更新用户*/
    @RequestMapping(value = "/getupdate")
    @ResponseBody
    public Integer getupdate(@RequestBody RiskLimit riskLimit){
         riskLimit.setModifier(SecurityContextHolder.getContext().getAuthentication().getName());
         return riskService.updateRiskLimit(riskLimit);
    }

    /* 删除用户 */
    @RequestMapping(value = "/getdelete")
    @ResponseBody
    public Integer getdelete(@RequestBody int id) {
          return riskService.deleteRiskLimitById(id);
    }

    /*批量删除模块*/
   @RequestMapping(value= "/getindefinitelyBatchDel")
    @ResponseBody
    public Integer getindefinitelyBatchDel(@RequestBody String[] idArr){
       return  riskService.deleteBatchRiskLimit(idArr);
    }


    /*
     *  风控限额管理模块
     */

     /*获取风控限额管理表的数据 */
     @SystemLogInfo( description = "limit")
     @RequestMapping(value = "/getLimit")
     @ResponseBody
     public  List<RiskQuota>  getLimit() {
          return riskService.getLimit();
     }

     /* 启用与禁用模块*/
     @RequestMapping(value = "/getlimitLocked")
     @ResponseBody
     public Boolean getlimitLocked(@RequestBody RiskQuota riskQuota) {
          return riskService.updateRiskQuotaLocked(riskQuota);
     }

     /* 新增用户模块 */
     @RequestMapping(value = "/getlimitAdd")
     @ResponseBody
     public Boolean getadd(@RequestBody RiskQuota riskQuota) {
        riskQuota.setCreator(SecurityContextHolder.getContext().getAuthentication().getName());
        return riskService.addRiskQuota(riskQuota);
     }

    /*判断是否可以添加*/
    @RequestMapping(value = "/getlimitAddCount")
    @ResponseBody
    public Integer getlimitAddCount(@RequestBody RiskQuota riskQuota){
        return riskService.insertRiskQuota(riskQuota);
    }
     /* 更新用户模块 */
     @RequestMapping(value = "/getlimitUpdate")
     @ResponseBody
     public Boolean getlimitUpdate(@RequestBody RiskQuota riskQuota) {
         riskQuota.setModifier(SecurityContextHolder.getContext().getAuthentication().getName());
         return riskService.updateRiskQuota(riskQuota);
     }

     /* 删除用户模块 */
     @RequestMapping(value = "/getlimitDeleted")
     @ResponseBody
     public Boolean getlimitDeleted(@RequestBody long id) {
         return riskService.deleteRiskQuotaByid(id);
     }

     /*批量删除模块*/
     @RequestMapping(value = "/getlimitBatchDel")
     @ResponseBody
     public Integer getlimitBatchDel(@RequestBody String[] idArr){
        return riskService.deleteBatchRiskQuota(idArr);
     }


     /*
      *   风控拒绝管理模块
      */

     /* 获取风控拒绝管理表的数据*/
     @SystemLogInfo( description = "refused")
     @RequestMapping(value = "/getRefused")
     @ResponseBody
     public List<RiskRefuse> getRefused(){
         return riskService.getRefuse();
     }

     /*启用与禁用模块*/
     @RequestMapping(value = "/getrefusedLocked")
     @ResponseBody
     public Boolean getrefusedLocked(@RequestBody RiskRefuse riskRefuse) {
         return riskService.updaterefusedLocked(riskRefuse);
     }

     /*新增用户模块*/
     @RequestMapping(value = "/getrefusedAdd")
     @ResponseBody
     public Boolean getrefusedAdd(@RequestBody RiskRefuse riskRefuse) {
         riskRefuse.setCreator(SecurityContextHolder.getContext().getAuthentication().getName());
         return riskService.addRiskRefuse(riskRefuse);
     }

     /*判断是否可以添加*/
     @RequestMapping(value = "/getrefusedAddCount")
     @ResponseBody
     public Integer getrefusedAddCount(@RequestBody RiskRefuse riskRefuse){
         return riskService.insertRiskRefuse(riskRefuse);
     }

     /*更新用户模块*/
     @RequestMapping(value = "/getrefusedUpdate")
     @ResponseBody
     public Boolean getrefusedUpdate(@RequestBody RiskRefuse riskRefuse) {
         riskRefuse.setModifier(SecurityContextHolder.getContext().getAuthentication().getName());
         return riskService.updateRiskRefuse(riskRefuse);
     }

     /*删除用户模块*/
     @RequestMapping(value = "/getrefusedDeleted")
     @ResponseBody
     public Boolean getrefusedDeleted(@RequestBody long id) {
         return riskService.deleteRiskRefuse(id);
     }

     /*批量删除模块*/
     @RequestMapping(value = "/getrefusedBatchDel")
     @ResponseBody
     public Integer getrefusedBatchDel(@RequestBody String[] idArr){
        return riskService.deleteBatchRiskRefuse(idArr);
     }

     /*
      *  外置风控管理模块
      */
     /* 获取外置风控表的数据*/
     @SystemLogInfo( description = "outer")
     @RequestMapping(value = "/getOuter")
     @ResponseBody
     public List<RiskExtend> getOuter() {
          return riskService.getOuter();
     }
     /* 启用与禁用模块*/
     @RequestMapping(value = "/getouterLocked")
     @ResponseBody
     public Boolean getouterLocked(@RequestBody RiskExtend riskExtend) {
         return riskService.updateouterLocked(riskExtend);
     }
     /*新增用户模块*/
     @RequestMapping(value = "/getouterAdd")
     @ResponseBody
     public Boolean getouterAdd(@RequestBody RiskExtend riskExtend) {
         riskExtend.setCreator(SecurityContextHolder.getContext().getAuthentication().getName());
         return riskService.addRiskExtend(riskExtend);
     }
     /*判断用户能否添加数据*/
     @RequestMapping(value = "/getouterAddCount")
     @ResponseBody
     public Integer getouterAddCount(@RequestBody RiskExtend riskExtend) {
         return  riskService.insertRiskExtend(riskExtend);
     }
     /*更新用户模块*/
     @RequestMapping(value = "/getouterUpdate")
     @ResponseBody
     public Boolean getouterUpdate(@RequestBody RiskExtend riskExtend) {
         riskExtend.setModifier(SecurityContextHolder.getContext().getAuthentication().getName());
         return riskService.updateRiskExtend(riskExtend);
     }
     /*删除用户模块*/
     @RequestMapping(value = "/getouterDeleted")
     @ResponseBody
     public Boolean getouterDeleted(@RequestBody Long id) {
         return riskService.deleteRiskExtend(id);
     }

     /*批量删除模块*/
     @RequestMapping(value = "/getouterBatchDel")
     @ResponseBody
     public Integer getouterBatchDel(@RequestBody String[] idArr){
         return  riskService.deleteBatchRiskExtend(idArr);
     }

    /**
     * 黑卡库管理模块
     */
     //获取黑卡库表的数据
      @SystemLogInfo( description = "blackcard")
      @RequestMapping(value="/getBlackcard")
      @ResponseBody
      public List<RiskDanger> getBlackcard(){
          return riskService.getBlackcard();
      }
     //启用与禁用模块
     @RequestMapping(value="/getblackcardLocked")
     @ResponseBody
     public Boolean getblackcardLocked(@RequestBody RiskDanger riskDanger){
          return  riskService.updateblackcardLocked(riskDanger);
     }
     //新增用户模块
     @RequestMapping(value="/getblackcardAdd")
     @ResponseBody
     public Boolean getblackcardAdd(@RequestBody RiskDanger riskDanger) {
         riskDanger.setCreator(SecurityContextHolder.getContext().getAuthentication().getName());
          return riskService.addRiskDanger(riskDanger);
     }
     //判断是否可以添加
    @RequestMapping(value = "/getblackcardAddCount")
    @ResponseBody
    public Integer getblackcardAddCount(@RequestBody RiskDanger riskDanger) {
          return riskService.insertRiskDanger(riskDanger);
    }
     //更新用户模块
     @RequestMapping(value="/getblackcardUpdate")
     @ResponseBody
     public Boolean getblackcardUpdate(@RequestBody RiskDanger riskDanger) {
         riskDanger.setModifier(SecurityContextHolder.getContext().getAuthentication().getName());
          return  riskService.updateRiskDanger(riskDanger);
     }
     //删除用户模块
     @RequestMapping(value="/getblackcardDeleted")
     @ResponseBody
     public Boolean getblackcardDeleted(@RequestBody Long id) {
          return  riskService.deleteRiskDanger(id);
     }
     //黑卡库批量删除模块
    @RequestMapping(value="/getblackcardBatchDel")
    @ResponseBody
    public Integer getblackcardBatchDel(@RequestBody String[] idArr){
         return riskService.deleteBatchRiskDanger(idArr);
    }
    /**
     *  商务卡管理
     */
    //获取商务卡表的数据
    @SystemLogInfo( description = "business")
    @RequestMapping(value="/getBusiness")
    @ResponseBody
    public List<RiskBusiness> getBusiness() {
        return riskService.getBusiness();
    }
    //新增操作
    @RequestMapping(value="/getbusinessAdd")
    @ResponseBody
    public Boolean getbusinessAdd(@RequestBody RiskBusiness riskBusiness) {
        riskBusiness.setCreator(SecurityContextHolder.getContext().getAuthentication().getName());
        return riskService.addRiskBusiness(riskBusiness);
    }
    //判断是否可以添加
    @RequestMapping(value = "/getbusinessAddCount")
    @ResponseBody
    public Integer getbusinessAddCount(@RequestBody RiskBusiness riskBusiness){
        return riskService.insertRiskBusiness(riskBusiness);
    }
    //更新操作
    @RequestMapping(value="/getbusinessUpdate")
    @ResponseBody
    public Boolean getbusinessUpdate(@RequestBody RiskBusiness riskBusiness) {
        riskBusiness.setModifier(SecurityContextHolder.getContext().getAuthentication().getName());
        return  riskService.updateRiskBusiness(riskBusiness);
    }
    //批量删除操作
    @RequestMapping(value="/getbusinessBatchDel")
    @ResponseBody
    public Integer getbusinessBatchDel(@RequestBody String[] idArr){
       return  riskService.deleteBatchRiskBusiness(idArr);

    }

    /**
     *  发卡行管理
     */
    //获取发卡行表的数据
    @SystemLogInfo( description = "issuer")
    @RequestMapping(value="/getIssuer")
    @ResponseBody
    public List<RiskIssuer> getIssuer() {
        return riskService.getIssuer();
    }
    //新增操作
    @RequestMapping(value="/getissuerAdd")
    @ResponseBody
    public Boolean getissuerAdd(@RequestBody RiskIssuer riskIssuer) {
        riskIssuer.setCreator(SecurityContextHolder.getContext().getAuthentication().getName());
        return  riskService.addRiskIssuer(riskIssuer);
    }
    //判断是否可以添加
    @RequestMapping(value = "/getissuerAddCount")
    @ResponseBody
    public Integer getissuerAddCount(@RequestBody RiskIssuer riskIssuer) {
       return riskService.insertRiskIssuer(riskIssuer);
    }
    //更新操作
    @RequestMapping(value="/getissuerUpdate")
    @ResponseBody
    public Boolean getissuerUpdate(@RequestBody RiskIssuer riskIssuer) {
        riskIssuer.setModifier(SecurityContextHolder.getContext().getAuthentication().getName());
        return riskService.updateRiskIssuer(riskIssuer);
    }
    //批量删除操作
    @RequestMapping(value="/getissuerBatchDel")
    @ResponseBody
    public Integer getissuerBatchDel(@RequestBody String[] idArr){
      return  riskService.deleteBatchRiskIssuer(idArr);
    }

}
